package com.kc.business.service.impl;

import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.RandomUtil;
import com.alibaba.fastjson.JSONObject;
import com.kc.business.domain.dto.BizOrderCompareStatisticsDTO;
import com.kc.business.domain.order.dto.BizOrderUserCardDTO;
import com.kc.business.domain.order.entity.BizOrderStatistics;
import com.kc.business.domain.query.BizOrderStatisticsQuery;
import com.kc.business.mapper.BizOrderStatisticsMapper;
import com.kc.business.service.BizOrderStatisticsService;
import com.kc.common.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;

/**
 * @ClassName BizOrderStatisticsServiceImpl
 * @Description TODO
 * @Author wangdongliang
 * @Date 2021/5/19 16:21
 */
@Service
@Slf4j
public class BizOrderStatisticsServiceImpl implements BizOrderStatisticsService {
    @Resource
    private RedisTemplate redisTemplate;
    @Resource
    private BizOrderStatisticsMapper bizOrderStatisticsMapper;
    @Override
    public List<BizOrderStatistics> getList(BizOrderStatisticsQuery bizOrderStatisticsQuery) {
        List<BizOrderStatistics> bizOrderStatisticsList = new ArrayList<>();
        //日期处理
        String endDate = bizOrderStatisticsQuery.getEndDate();
        String beginDate = bizOrderStatisticsQuery.getBeginDate();
        //当前日期
        String currDate = DateUtil.now().substring(0,10);
        while(true){
            if(beginDate.equals(currDate)){
                //todo 当前日期, 查询订单表
                BizOrderStatistics bizOrderStatistics = getCurrData(beginDate,0,0,0);
                bizOrderStatisticsList.add(bizOrderStatistics);
            }else{
                //非当前日期，查询统计表
                BizOrderStatistics bizOrderStatistics = getHistoryData(beginDate,0,0,0,bizOrderStatisticsQuery);
                bizOrderStatisticsList.add(bizOrderStatistics);
            }
            beginDate = DateUtil.offset(DateUtil.parse(beginDate), DateField.DAY_OF_MONTH,1).toString().substring(0,10);
            if(beginDate.equals(endDate)){
                if(beginDate.equals(currDate)){
                    //todo 当前日期, 查询订单表
                    BizOrderStatistics bizOrderStatistics = getCurrData(beginDate,0,0,0);
                    bizOrderStatisticsList.add(bizOrderStatistics);
                }else{
                    //非当前日期，查询统计表
                    BizOrderStatistics bizOrderStatistics = getHistoryData(beginDate,0,0,0,bizOrderStatisticsQuery);
                    bizOrderStatisticsList.add(bizOrderStatistics);
                }
                break;
            }
        }
        return bizOrderStatisticsList;
    }

    @Override
    public List<BizOrderCompareStatisticsDTO> getCompareDataByDate(List<BizOrderStatistics> bizOrderStatisticsList, BizOrderStatisticsQuery bizOrderStatisticsQuery,String attributeName) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
        //获取开始日期前一天数据
        String beginDate = bizOrderStatisticsQuery.getBeginDate();
        BizOrderStatistics bizOrderStatistics = new BizOrderStatistics();
        if(StringUtils.isNotEmpty(bizOrderStatisticsQuery.getBeginDate())) {
            bizOrderStatistics = getHistoryData(DateUtil.offset(DateUtil.parse(beginDate), DateField.DAY_OF_MONTH, -1).toString().substring(0, 10), 0, 0, 0,bizOrderStatisticsQuery);
        }else{
            if(bizOrderStatisticsQuery.getIsQuarter() == 0) {
                bizOrderStatistics = getHistoryData(DateUtil.offset(DateUtil.parse(bizOrderStatisticsQuery.getBeginMonth() + "-01"), DateField.MONTH, -1).toString().substring(0, 7), 0, 0, 1, bizOrderStatisticsQuery);
            }else{
                int q = DateUtil.quarter(DateUtil.parse(DateUtil.now()));
                if(q == 1){
                    bizOrderStatisticsQuery.setYear(bizOrderStatisticsQuery.getYear()-1);
                    bizOrderStatisticsQuery.setQuarter(4);
                }else{
                    bizOrderStatisticsQuery.setQuarter(bizOrderStatisticsQuery.getQuarter()-1);
                }
                bizOrderStatistics = getHistoryData(DateUtil.now(),0,0,2,bizOrderStatisticsQuery);
            }
        }
        //计算客单价
        if(bizOrderStatistics.getOrderUserNum() != 0){
            bizOrderStatistics.setSingleUserMoney((bizOrderStatistics.getOrderMoney().intValue()/bizOrderStatistics.getOrderUserNum()));
        }


        int length = bizOrderStatisticsList.size();
        //金额
        BizOrderCompareStatisticsDTO orderMoney = getOrderStatisticsDTO("当期","bar","");
        List<String> orderMoneyList = new ArrayList<>();
        //环比(前一天)
        BizOrderCompareStatisticsDTO orderMoney1 = getOrderStatisticsDTO("环比","bar","");
        List<String> orderMoneyList1 = new ArrayList<>();
        //同比(上一年)
        BizOrderCompareStatisticsDTO orderMoney2 = getOrderStatisticsDTO("同比","bar","");
        List<String> orderMoneyList2 = new ArrayList<>();
        BizOrderStatistics orderStatistics = new BizOrderStatistics();
        for(int i = 0;i < length;i++){
            orderStatistics = bizOrderStatisticsList.get(i);
            Method m = orderStatistics.getClass().getMethod("get" + attributeName);
            Object value = m.invoke(orderStatistics);
            orderMoneyList.add(value.toString());
            if(i == 0){
                 m = bizOrderStatistics.getClass().getMethod("get" + attributeName);
                 value = m.invoke(bizOrderStatistics);
                 orderMoneyList1.add(value.toString());
            }else{
                orderStatistics = bizOrderStatisticsList.get(i-1);
                m = orderStatistics.getClass().getMethod("get" + attributeName);
                value = m.invoke(orderStatistics);
                orderMoneyList1.add(value.toString());
            }
            if(StringUtils.isNotEmpty(bizOrderStatisticsQuery.getBeginDate())) {
                orderStatistics = getHistoryData(DateUtil.offset(DateUtil.parse(beginDate), DateField.YEAR, -1).toString().substring(0, 10), 0, 0, 0,bizOrderStatisticsQuery);
            }else{
                if(bizOrderStatisticsQuery.getIsQuarter() == 1){
                    bizOrderStatisticsQuery.setYear(bizOrderStatisticsQuery.getYear()-1);
                    orderStatistics = getHistoryData(DateUtil.now(),0,0,2,bizOrderStatisticsQuery);
                }else {
                    orderStatistics = getHistoryData(DateUtil.offset(DateUtil.parse(bizOrderStatisticsQuery.getBeginMonth() + "-01"), DateField.YEAR, -1).toString().substring(0, 7), 0, 0, 1, bizOrderStatisticsQuery);
                }
            }
            //计算客单价
            if(orderStatistics.getOrderUserNum() != 0){
                orderStatistics.setSingleUserMoney((orderStatistics.getOrderMoney().intValue()/orderStatistics.getOrderUserNum()));
            }
            m = orderStatistics.getClass().getMethod("get" + attributeName);
            value = m.invoke(orderStatistics);
            orderMoneyList2.add(value.toString());
        }
        orderMoney.setData(orderMoneyList);
        orderMoney1.setData(orderMoneyList1);
        orderMoney2.setData(orderMoneyList2);
        List<BizOrderCompareStatisticsDTO> bizOrderStatisticsDTOList = new ArrayList<>();
        bizOrderStatisticsDTOList.add(orderMoney);
        bizOrderStatisticsDTOList.add(orderMoney1);
        bizOrderStatisticsDTOList.add(orderMoney2);
        return bizOrderStatisticsDTOList;
    }

    @Override
    public List<BizOrderStatistics> getListByMonth(BizOrderStatisticsQuery bizOrderStatisticsQuery) {
        String currMonth = DateUtil.now().toString().substring(0,7);
        String beginMonth = bizOrderStatisticsQuery.getBeginMonth();
        String endMonth = bizOrderStatisticsQuery.getEndMonth();
        List<BizOrderStatistics> bizOrderStatisticsList = new ArrayList<>();
        while(true){
            BizOrderStatistics bizOrderStatistics = getHistoryData(beginMonth,0,0,1,bizOrderStatisticsQuery);
            bizOrderStatisticsList.add(bizOrderStatistics);
            beginMonth = DateUtil.offset(DateUtil.parse(beginMonth+"-01"), DateField.MONTH,1).toString().substring(0,7);
            if(beginMonth.equals(currMonth)){
                //查询当天数据
                BizOrderStatistics currDayData = getCurrData(DateUtil.now().toString().substring(0,10),0,0,0);
                bizOrderStatistics = getHistoryData(beginMonth,0,0,1,bizOrderStatisticsQuery);
                objAdd(bizOrderStatistics,currDayData);
                bizOrderStatisticsList.add(bizOrderStatistics);
            }
            if(beginMonth.equals(endMonth)) {
                if(!beginMonth.equals(currMonth)){
                    //最后结束月份不等于当前月份，查数据,不包含当月
                    bizOrderStatistics = getHistoryData(beginMonth,0,0,1,bizOrderStatisticsQuery);
                    bizOrderStatisticsList.add(bizOrderStatistics);
                }
                break;
            }
        }
        return bizOrderStatisticsList;
    }

    @Override
    public List<BizOrderStatistics> getKcRefundStatistics(BizOrderStatisticsQuery bizOrderStatisticsQuery) {
        List<BizOrderStatistics> bizOrderStatisticsList = new ArrayList<>();
        //日期处理
        String endDate = bizOrderStatisticsQuery.getEndDate();
        String beginDate = bizOrderStatisticsQuery.getBeginDate();
        if(StringUtils.isNotEmpty(bizOrderStatisticsQuery.getMonth())){
            beginDate = bizOrderStatisticsQuery.getMonth()+"-01";
            endDate = DateUtil.endOfMonth(DateUtil.parse(bizOrderStatisticsQuery.getMonth()+"-01")).toString().substring(0,10);
        }else if(bizOrderStatisticsQuery.getYear() != null){
            endDate = bizOrderStatisticsQuery.getYear()+"-12";
            beginDate = bizOrderStatisticsQuery.getYear()+"-01";
        }
//        if(StringUtils.isEmpty(bizOrderStatisticsQuery.getBeginDate())){
//            endDate = bizOrderStatisticsQuery.getEndMonth();
//            beginDate = bizOrderStatisticsQuery.getBeginMonth();
//            bizOrderStatisticsQuery.setBeginDate(bizOrderStatisticsQuery.getMonth()+"-01");
//            bizOrderStatisticsQuery.setEndDate(DateUtil.endOfMonth(DateUtil.parse(bizOrderStatisticsQuery.getMonth()+"-01")).toString().substring(0,10));
//        }
        while(true){
            if(bizOrderStatisticsQuery.getYear() == null) {
                //日统计
                bizOrderStatisticsList.add(getRefundStatisticsInfo(beginDate, 0));
                beginDate = DateUtil.offset(DateUtil.parse(beginDate), DateField.DAY_OF_MONTH, 1).toString().substring(0, 10);
                if (beginDate.equals(endDate)) {
                    bizOrderStatisticsList.add(getRefundStatisticsInfo(beginDate, 0));
                    break;
                }
            }else{
                //月统计
                bizOrderStatisticsList.add(getRefundStatisticsInfo(beginDate, 1));
                beginDate = DateUtil.offset(DateUtil.parse(beginDate+"-01"), DateField.MONTH, 1).toString().substring(0, 7);
                if (beginDate.equals(endDate)) {
                    bizOrderStatisticsList.add(getRefundStatisticsInfo(beginDate, 1));
                    break;
                }
            }
        }
        //String date = "2020-12-10";
        //bizOrderStatisticsList.add(getRefundStatisticsInfo(date,0));
        return bizOrderStatisticsList;
    }

    @Override
    public List<BizOrderCompareStatisticsDTO> getRefundCompareData(List<BizOrderStatistics> bizOrderStatisticsList, BizOrderStatisticsQuery bizOrderStatisticsQuery,String attributeName) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
        //获取开始日期前一天数据
        String beginDate = bizOrderStatisticsQuery.getBeginDate();
        BizOrderStatistics bizOrderStatistics = new BizOrderStatistics();
        if(bizOrderStatisticsQuery.getYear() == null) {
            //log.info("ssssssss{}",bizOrderStatisticsQuery);
            if(StringUtils.isNotEmpty(bizOrderStatisticsQuery.getMonth())){
                beginDate = bizOrderStatisticsQuery.getMonth()+"-01";
            }
            bizOrderStatistics = getRefundStatisticsInfo(DateUtil.offset(DateUtil.parse(beginDate), DateField.DAY_OF_MONTH, -1).toString().substring(0, 10), 0);
        }else{
            beginDate = bizOrderStatisticsQuery.getYear() + "-1";
            bizOrderStatistics = getRefundStatisticsInfo(DateUtil.offset(DateUtil.parse(beginDate+"-01"), DateField.MONTH, -1).toString().substring(0, 7),  1);
        }

        int length = bizOrderStatisticsList.size();
        //金额
        BizOrderCompareStatisticsDTO orderMoney = getOrderStatisticsDTO("当期","bar","");
        List<String> orderMoneyList = new ArrayList<>();
        //环比(前一天)
        BizOrderCompareStatisticsDTO orderMoney1 = getOrderStatisticsDTO("环比","bar","");
        List<String> orderMoneyList1 = new ArrayList<>();
        //同比(上一年)
        BizOrderCompareStatisticsDTO orderMoney2 = getOrderStatisticsDTO("同比","bar","");
        List<String> orderMoneyList2 = new ArrayList<>();
        BizOrderStatistics orderStatistics = new BizOrderStatistics();
        for(int i = 0;i < length;i++){
            orderStatistics = bizOrderStatisticsList.get(i);
            Method m = orderStatistics.getClass().getMethod("get" + attributeName);
            Object value = m.invoke(orderStatistics);
            orderMoneyList.add(value.toString());
            if(i == 0){
                m = bizOrderStatistics.getClass().getMethod("get" + attributeName);
                value = m.invoke(bizOrderStatistics);
                orderMoneyList1.add(value.toString());
            }else{
                orderStatistics = bizOrderStatisticsList.get(i-1);
                m = orderStatistics.getClass().getMethod("get" + attributeName);
                value = m.invoke(orderStatistics);
                orderMoneyList1.add(value.toString());
            }
            if(bizOrderStatisticsQuery.getYear() != null) {
                orderStatistics = getRefundStatisticsInfo(DateUtil.offset(DateUtil.parse(beginDate), DateField.YEAR, -1).toString().substring(0, 10),  1);
            }else{
                //orderStatistics = getRefundStatisticsInfo(DateUtil.offset(DateUtil.parse(bizOrderStatisticsQuery.getBeginMonth()+"-01"), DateField.YEAR, -1).toString().substring(0, 7),  1);
                orderStatistics = getRefundStatisticsInfo(DateUtil.offset(DateUtil.parse(beginDate), DateField.DAY_OF_MONTH, -1).toString().substring(0, 10), 0);
            }
            m = orderStatistics.getClass().getMethod("get" + attributeName);
            value = m.invoke(orderStatistics);
            orderMoneyList2.add(value.toString());
        }
        orderMoney.setData(orderMoneyList);
        orderMoney1.setData(orderMoneyList1);
        orderMoney2.setData(orderMoneyList2);
        List<BizOrderCompareStatisticsDTO> bizOrderStatisticsDTOList = new ArrayList<>();
        bizOrderStatisticsDTOList.add(orderMoney);
        bizOrderStatisticsDTOList.add(orderMoney1);
        bizOrderStatisticsDTOList.add(orderMoney2);
        return bizOrderStatisticsDTOList;
    }

    @Override
    public List<BizOrderStatistics> getListByQuarter(BizOrderStatisticsQuery bizOrderStatisticsQuery) {
        //当天日期
        String currDate = DateUtil.now().substring(0,10);
        List<BizOrderStatistics> bizOrderStatisticsList = new ArrayList<>();
        //当前季度
        int quarter = DateUtil.quarter(DateUtil.parse(currDate));
        for(int i = 1;i<=4;i++){
            bizOrderStatisticsQuery.setQuarter(i);
            BizOrderStatistics bizOrderStatistics = getHistoryData(currDate,0,0,2,bizOrderStatisticsQuery);
            bizOrderStatistics.setYearQ(i);
            if(i == quarter){
                //查询当天数据
                BizOrderStatistics currDayDate = getCurrData(currDate,0,0,0);
                objAdd(bizOrderStatistics,currDayDate);
            }
            bizOrderStatisticsList.add(bizOrderStatistics);
        }
        return bizOrderStatisticsList;
    }

    public BizOrderStatistics getRefundStatisticsInfo(String date,Integer dateType){
        BizOrderStatistics bizOrderStatistics = bizOrderStatisticsMapper.getKcRefundStatistics(date,dateType);
        bizOrderStatistics = getDetail(bizOrderStatistics,date);
        statisticsOrderByDateUserNum(bizOrderStatistics,dateType);
        return bizOrderStatistics;
    }

    /**
     * 统计用户数量
     * @param bizOrderStatistics
     * @return
     */
    public BizOrderStatistics statisticsOrderByDateUserNum(BizOrderStatistics bizOrderStatistics,Integer dateType){
        bizOrderStatistics.setDateType(dateType);
        List<BizOrderUserCardDTO> bizOrderUserCardDTOS = bizOrderStatisticsMapper.getKcRefundUserStatistics(bizOrderStatistics);
        //总用户数
        Integer orderUserNum = 0;
        //男士数量
        Integer manNum = 0;
        //男性订单金额
        BigDecimal manOrderMoney = new BigDecimal(0);
        //女士数量
        Integer womanNum = 0;
        //女性订单金额
        BigDecimal womanOrderMoney = new BigDecimal(0);

        //未注册人员数量
        Integer other = 0;
        //未实名用户订单金额
        BigDecimal otherOrderMoney = new BigDecimal(0.0);
        if(bizOrderStatistics != null){
            for(BizOrderUserCardDTO orderUserCardDTO : bizOrderUserCardDTOS){
                orderUserNum += 1;
                if(StringUtils.isNotEmpty(orderUserCardDTO.getCard())){
                    Integer num = Integer.parseInt(orderUserCardDTO.getCard().substring(16,17));
                    if(num % 2 == 0){
                        //女性
                        womanNum += 1;
                        womanOrderMoney = womanOrderMoney.add(orderUserCardDTO.getOrderMoney());

                    }else{
                        //男性
                        manNum += 1;
                        manOrderMoney = manOrderMoney.add(orderUserCardDTO.getOrderMoney());
                    }
                }else{
                    other += 1;
                    otherOrderMoney = otherOrderMoney.add(orderUserCardDTO.getOrderMoney());
                }

            }
        }
        bizOrderStatistics.setOrderUserNum(orderUserNum);
        bizOrderStatistics.setManNum(manNum);
        bizOrderStatistics.setWomanNum(womanNum);
        bizOrderStatistics.setOther(other);

        bizOrderStatistics.setManOrderMoney(manOrderMoney);
        bizOrderStatistics.setWomanOrderMoney(womanOrderMoney);
        bizOrderStatistics.setOtherOrderMoney(otherOrderMoney);
        return null;
    }

    public BizOrderCompareStatisticsDTO getOrderStatisticsDTO(String name,String type,String color){
        BizOrderCompareStatisticsDTO bizOrderStatisticsDTO = new BizOrderCompareStatisticsDTO();
        bizOrderStatisticsDTO.setName(name);
        bizOrderStatisticsDTO.setType(type);
        bizOrderStatisticsDTO.setColor(color);
        return bizOrderStatisticsDTO;
    }

    /**
     * 两个类相加
     * @param obj1
     * @param obj2
     */
    public void objAdd(BizOrderStatistics obj1,BizOrderStatistics obj2){
        obj1.setOrderNum(obj1.getOrderUserNum() + obj2.getOrderNum());
        obj1.setOrderMoney(obj1.getOrderMoney().add(obj2.getOrderMoney()));
        obj1.setCostMoney(obj1.getCostMoney().add(obj2.getCostMoney()));
        obj1.setManNum(obj1.getManNum()+obj2.getManNum());
        obj1.setManOrderMoney(obj1.getManOrderMoney().add(obj2.getManOrderMoney()));
        obj1.setOrderUserNum(obj1.getOrderUserNum() + obj2.getOrderUserNum());
        obj1.setWomanNum(obj1.getWomanNum() + obj2.getWomanNum());
        obj1.setWomanOrderMoney(obj1.getWomanOrderMoney().add(obj2.getWomanOrderMoney()));
        obj1.setOther(obj1.getOther() + obj2.getOther());
        obj1.setOtherOrderMoney(obj1.getOtherOrderMoney().add(obj2.getOtherOrderMoney()));

    }
    /**
     * 获取历史日期数据
     * @param currDate
     * @param platformId
     * @param platformType
     * @param dateType 日期类型:0 按日，1按月，2 按照
     * @return
     */
    @Override
    public BizOrderStatistics getHistoryData(String currDate,Integer platformId,Integer platformType,Integer dateType,BizOrderStatisticsQuery bizOrderStatisticsQuery){
        String key = "order:statistics:"+platformId+":"+platformType+":"+currDate+":"+dateType;
        Object obj = redisTemplate.opsForValue().get(key);
        if(obj == null) {
            BizOrderStatistics bizOrderStatistics;
            try {
                bizOrderStatistics = bizOrderStatisticsMapper.getHistoryData(currDate, dateType, bizOrderStatisticsQuery);
                if (bizOrderStatistics == null) {
                    bizOrderStatistics = new BizOrderStatistics();
                    bizOrderStatistics.setPlatformId(0);
                }
            }catch (Exception e){
                bizOrderStatistics = new BizOrderStatistics();
            }
            getDetail(bizOrderStatistics, currDate);
            //数据写入redis
            String jsonString = JSONObject.toJSONString(bizOrderStatistics);

            return bizOrderStatistics;
        }else{
            BizOrderStatistics bizOrderStatistics = JSONObject.parseObject(obj.toString(),BizOrderStatistics.class);
            return bizOrderStatistics;
        }
    }

    /**
     * 获取当前日期数据
     * @param currDate
     * @param platformId
     * @param platformType
     * @return
     */
    @Override
    public BizOrderStatistics getCurrData(String currDate,Integer platformId,Integer platformType,Integer dateType){
        String key = "order:statistics:"+platformId+":"+platformType+":"+currDate;
        Object obj = redisTemplate.opsForValue().get(key);
        if(obj == null) {
            BizOrderStatistics bizOrderStatistics;
            try {
                bizOrderStatistics =bizOrderStatisticsMapper.statisticsOrderByData(currDate, dateType);
                if (bizOrderStatistics == null || bizOrderStatistics.getPlatformId() == null) {
                    bizOrderStatistics = new BizOrderStatistics();
                }
            }catch (Exception e){
                bizOrderStatistics = new BizOrderStatistics();
            }
            bizOrderStatistics.setPlatformId(0);
            getDetail(bizOrderStatistics, currDate);
            String jsonString = JSONObject.toJSONString(bizOrderStatistics);
            //缓存300秒
            redisTemplate.opsForValue().set(key, jsonString, 300, TimeUnit.SECONDS);
            return bizOrderStatistics;
        }else{
            BizOrderStatistics bizOrderStatistics = JSONObject.parseObject(obj.toString(),BizOrderStatistics.class);
            return bizOrderStatistics;
        }
    }
    private BizOrderStatistics getDetail(BizOrderStatistics bizOrderStatistics,String date){
        if(bizOrderStatistics == null){
            bizOrderStatistics = new BizOrderStatistics();
            bizOrderStatistics.setPlatformId(0);
        }
        if(StringUtils.isEmpty(date)){
            date = DateUtil.now();
        }
        bizOrderStatistics.setCurrYear(date.substring(0,4));
        bizOrderStatistics.setCurrMonth(date.substring(0,7));
        try {
            bizOrderStatistics.setYearDay(date.substring(0, 10));
        }catch (Exception e){
            bizOrderStatistics.setYearDay("");
        }
        bizOrderStatistics.setYearQ(1);
        return bizOrderStatistics;
        //bizOrderStatistics.setYearQ(DateUtil.quarter(DateUtil.parse(date)));
    }
}
